<?php

class Email_model extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    function sendEmail($emailTo, $title, $message) {
        $option = new Option();
        $option->where('key', 'email')->get();
        $email = $option->value;        

        $option = new Option();
        $option->where('key', 'email_pass')->get();
        $pass = $option->value;

        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'ssl://smtp.googlemail.com';
        $config['smtp_port'] = '465';
        $config['smtp_timeout'] = '30';
        $config['smtp_user'] = $email;
        $config['smtp_pass'] = $pass;
        $config['charset'] = 'utf-8';
        $config['newline'] = "\r\n";
        $config['mailtype'] = 'html';
        $this->email->initialize($config);
        //Send Mail
        $this->email->from($email, 'IFree - Contact');

        //Email
        $this->email->to($emailTo);
        $this->email->subject($title);
        $this->email->message($message);
        $this->email->send();
    }

}

?>
